"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/11/6 10:42
@Description :  线程的使用
线程的参数传递
"""
import os
import threading
import time
from threading import Thread


def sing(num,delay):
    for i in range(num):
        print("唱歌")
        time.sleep(delay)


def dance(num,delay):
    for i in range(num):
        print("跳舞")
        time.sleep(delay)


if __name__ == '__main__':
    # 创建线程
    thread1 = Thread(target=sing, args=(3,0.2))
    thread2 = Thread(target=dance,kwargs={'num':5,'delay':0.2})
    # 开启线程  抢占cpu的运行时间
    thread1.start()
    thread2.start()

    # 默认情况下  主线程需要等待所有子线程任务结束后才能结束
    print("------------主线程任务结束-------------")
